﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="xbrlesita_sidevahend", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(XbrlesitaSidevahend))]
    public class XbrlesitaSidevahendSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IXbrlesitaSidevahend clazz;
        
        public XbrlesitaSidevahendSerializer(IXbrlesitaSidevahend clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("liik");
            if (clazz.Liik!=null) {
                Writer.WriteTypeAttribute("http://producers.arireg.xtee.riik.ee/producer/arireg", "x_sideliik");
                Writer.WriteString(clazz.Liik.ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Liik");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("number");
            if (clazz.Number!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Number))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Number");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="liik") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrlesita_sidevahend>liik");
                }
                clazz.Liik = new global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.XSideliik(Reader.ReadElementString("liik"));
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesita_sidevahend>liik", Reader.LocalName);
            }
            if (Reader.LocalName=="number") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrlesita_sidevahend>number");
                }
                clazz.Number = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("number")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesita_sidevahend>number", Reader.LocalName);
            }
        }
    }
}
